package chapter01;

import java.util.Scanner;

public class obj_01 {
    public static void main(String[] args)
    {
        String str1 = new String();
        str1 = "hello";
        func1(str1);
        System.out.println("Main : str = " + str1 + "  hashcode : " + System.identityHashCode(str1));


        User user = new User();
        user.name = "zhangsan";
        func2(user);
        System.out.println("Main : username = " + user.name + " hashcode : " + System.identityHashCode(user));
    }
    public static void func2(User user) {
        user.name = "lisi";
        System.out.println("func2 : username = " + user.name + " hashcode : " + System.identityHashCode(user));
    }

    public static void func1(String str) {
        System.out.println("func1 : 没赋值前str的地址： " + System.identityHashCode(str));
        str += " world";
        System.out.println("func1 : str = " + str + "  hashcode : " + System.identityHashCode(str));
    }
}
class User
{
    public String name;
}

